# -*- coding: utf-8 -*-
# @Time:2021/07/08 21:43
# @Author:Cindy

import requests
import pytest


class TestCase:

    def setup_class(self):
        self.baseurl = 'http://127.0.0.1:5000/testcase'

    def teardown_class(self):
        pass

    def test_get(self):
        # 测试获取用例数据
        r = requests.get(self.baseurl, params={"id": 1})
        print(r.json())
        assert r.status_code == 200

    def test_post(self):
        data = {'id': 6, 'nodeid': ['node6', 'node7'], 'remark': 'remark6'}
        r = requests.post(self.baseurl, json=data)
        assert r.status_code == 200

    def test_put(self):
        data = {'id': 6, 'nodeid': 'node666', 'remark': 'remark666'}
        r = requests.put(self.baseurl, json=data)
        assert r.status_code == 200

    def test_delete(self):
        # delete case_id为空
        r = requests.delete(self.baseurl)
        assert r.status_code == 200
        assert r.json()['error'] == 40001
        # delete case_id不为空
        r = requests.delete(self.baseurl, params={'id': 1})
        assert r.status_code == 200
